local util = require("util")
local delaya = 6
local delayb = 9
--load config to dict
local cron_a = function (premature)
	if not  premature then
		util.ReloadConfig()
	end
end
local ngxpid = ngx.worker.id()
if ngxpid ~= nil then
	if 0 == ngxpid then
		--local ok, err = ngx.timer.at(delaya, cron_a)
		local ok, err = ngx.timer.every(delaya, cron_a)
		if not ok then
			ngx.log(ngx.ERR, "failed to create the timer: ", err)
			return
		end
	end
else
	local ok, err = ngx.timer.every(60, cron_a)
	if not ok then
		ngx.log(ngx.ERR, "failed to create the timer: ", err)
		return
	end
end

--sync 
local cron_b = function (premature)
	if not  premature then
		util.syncDictToTable()
	end

end		
local ok, err = ngx.timer.every(delayb, cron_b)
if not ok then
	ngx.log(ngx.ERR, "failed to create the timer: ", err)
	return
end
